<?php

require_once("../../controllers/init.php");
require_once($FILE_SYSTEM_ROOT."/controllers/authentication.php");
require_once($FILE_SYSTEM_ROOT."/model/classes/events/Event.php");

//echo $GLOBALS['SESSION_ID'];

if(!$GLOBALS['IS_LOGGED_ON'])
{
	echo "ERROR_NOT_LOGGED_ON";
	exit;
}


$EventID=$_POST['EventID'];

$Event=new Event($EventID);

$time = $Event->getStart()->format("H:i")." - ".$Event->getEnd()->format("H:i");
if($time=="00:00 - 00:00")$time="All day event";

//get Locations
$arrLocations = $Event->getLocations();
$locations="";
foreach($arrLocations as $location)
{
	$locations .= $GLOBALS['LOCATIONS'][$location]['LongName'].", ";
}

$locations = substr($locations,0,-2);
if($locations!="")$locations="<b>Where: </b>".$locations;

//get involvees
$arrEventInvolvees = $Event->getInvolvees();
$eventInvolvees="";
foreach($arrEventInvolvees as $eventInvolvee)
{
	$eventInvolvees .= $GLOBALS['INVOLVEES'][$eventInvolvee]['LongName'].", ";
}
$eventInvolvees = substr($eventInvolvees,0,-2);
if($eventInvolvees!="")$eventInvolvees="<b>Who: </b>".$eventInvolvees;

$eventDescription ="";
$eventComment ="";
$eventEventType ="";
$eventResponsible ="";

if($Event->getDescription()!="")$eventDescription="<b>Description: </b>".$Event->getDescription();
if($Event->getComment()!="")$eventComment="<b>Comment: </b>".$Event->getComment();
if($Event->getTypeID()!="")$eventEventType="<b>Event type: </b>".$GLOBALS['EVENTTYPES'][$Event->getTypeID()];
if($Event->getResponsible()!="")$eventResponsible="<b>Responsible: </b>".$Event->getResponsible();


?>

<div id="calendar-month-event-view-title">
	<?php echo $Event->getTitle();?>
	<div id="calendar-month-event-view-close">X</div>
	<div id="calendar-month-event-view-id"><?php echo $Event->getEventID();?></div>
</div>
<div id="calendar-month-event-view-container">
	<div id="calendar-month-event-view-date"><?php echo $Event->getStart()->format("l j F Y");?></div>
	<div id="calendar-month-event-view-time"><?php echo $time;?></div>
	<div id="calendar-month-event-view-deleted"><?php if($Event->getDeletedBy()!=0)echo "Deleted by ".$USERS[$Event->getDeletedBy()]['LongName']." on ".$Event->getDeletedWhen()->format("l j F Y \a\\t H:i");?></div>
	<div id="calendar-month-event-view-created"><?php echo "Created by ".$USERS[$Event->getCreatedBy()]['LongName']." on ".$Event->getCreatedWhen()->format("l j F Y \a\\t H:i");?></div>
	<div id="calendar-month-event-view-description"><?php echo $eventDescription ?></div>
	<div id="calendar-month-event-view-comment"><?php echo $eventComment ?></div>
	<div id="calendar-month-event-view-event-type"><?php echo $eventEventType ?></div>
	<div id="calendar-month-event-view-responsible"><?php echo $eventResponsible ?></div>
	
	
	<div id="calendar-month-event-view-locations"><?php echo $locations;?></div>
	<div id="calendar-month-event-view-involvees"><?php echo $eventInvolvees;?></div>
	<div id="calendar-month-event-view-edit-button">Edit</div>
</div>
